﻿@model Controller2.Models.Brainstorm_Topico
@{
    Layout = null;
}
<!DOCTYPE html>
<html class="no-js">
<head>
    <title>Cadastro</title>
    @(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.vista.css").Combined(true).Compress(true)))
    @if (false)
    {
        <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/themes/controller/controller.css")" rel="stylesheet" type="text/css" />
        <script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>    
        <script src="@Url.Content("~/Scripts/jquery.maskedinput-1.3.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
    }
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/controller.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/numbers.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
    <style type="text/css">
        fieldset
        {
            width: 550px;
        }
        .display-label, .editor-label
        {
            width: 120px;
            text-align: right;
            padding-right: 5px;
        }
        #IdCampanha, #IdPessoa
        {
            width: 400px;
        }
        input[type=text]#Topico
        {
            width: 400px;
        }
    </style>
    @if (false)
    {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/jquery-ui.js" type="text/javascript"></script>
        <script src="../../Scripts/controller.js" type="text/javascript"></script>
    }
</head>
<body id="frame">
    <div id="formHide">
        @using (Html.BeginForm("Salvar", "Brainstorm"))
        {
            @Html.ValidationSummary(true)
            <fieldset>
                <legend>Tópico do Brainstorm</legend>
                @Html.HiddenFor(model => model.IdTopico)
                <div class="editor-label">
                    @Html.LabelFor(model => model.DataCadastro, "Data de Cadastro: ")
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.DataCadastro)
                    @Html.ValidationMessageFor(model => model.DataCadastro)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Topico, "Tópico: ")
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.Topico, new { maxlength = "100", @class = "obrigatorio " })
                    @Html.ValidationMessageFor(model => model.Topico)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.IdCampanha, "Campanha: ")
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(model => model.IdCampanha, (IEnumerable<SelectListItem>)ViewBag.Campanha, String.Empty, new { @class = "obrigatorio " })
                    @Html.ValidationMessageFor(model => model.IdCampanha)
                </div>
                <div class="editor-label">
                    <label for="UserName">
                        Usuário:
                    </label>
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.UserName, new { @readonly = "readonly" })
                </div>
            </fieldset>        
            <div id="botoesForm">
                <input type="submit" id="Gravar" value="Gravar" />
                <input type="button" id="Fechar" value="Cancelar" />
            </div>
        }
    </div>
    <div id="alertaErro" style="display: none">
    </div>
    <script type="text/javascript">
        $(function () {
            $('#formHide').fadeIn('slow');
            hideLoading();
            $('#Topico').focus();
        });
        $('form').submit(function (e) {
            e.preventDefault();
            if ($('form').valid()) {
                $.post('@Url.Action("Salvar", "Brainstorm")', $('form').serialize(), function (data) {
                    if (data.salvo) {
                        closeWindow();
                    } else {
                        alertError(data.error);
                    }
                    $('#gravar').attr('disabled', false);
                });
            }
        });
        $('#Fechar').click(function () { closeWindow(); });
    </script>
</body>
</html>
